TidyFileCat for multiple FileCats.
Close the files the same way.Code:int main(){
FILE *f[20];
char FileName[20]; /* Plenty large for your file naming */
int i;
int NumberOfFiles = 20;
for (i=0; i<NumberOfFiles; i++){
sprintf(FileName,"Channel%d.txt",i);
f[i] = fopen(FileName,"r+");
}
}
But what if for some reason some of the files were closed and some were not closed as each file was delt with? Meow. How to check the status of each individual file?Code:
int main(){
FILE *f[20];
char FileName[20]; /* Plenty large for your file naming */
int i;
int NumberOfFiles = 20;
for (i=0; i<NumberOfFiles; i++){
sprintf(FileName,"Channel%d.txt",i);
f[i] = fopen(FileName,"r+");
}
/* close loop */
for (i=0; i<NumberOfFiles; i++){
sprintf(FileName,"Channel%d.txt",i);
f[i] = fclose(FileName);
}
}
What if the prog exits with out closing that many files or misses some. How to close the file after the prog exited or restarted? .... just open and close it again?
Just saying a open file after prog exited can be a problem.
Could you provide some reasons and examples for having multiple files open?

